package com.dynamic.idea.quick.develop.plugin.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 枚举类型的值
 */
public class ValueTypeUtils {

    private static Map<String,String> primitive2BoxMap=new HashMap<>();
    private static Map<String,String> box2primitiveMap=new HashMap<>();

    static {
        //包装类型
        box2primitiveMap.put("Integer","int");
        box2primitiveMap.put("Byte","byte");
        box2primitiveMap.put("Character","char");
        box2primitiveMap.put("Short","short");

        box2primitiveMap.put("Long","long");
//        box2primitiveMap.put("Float","float");
//        box2primitiveMap.put("Double","double");
//        box2primitiveMap.put("Boolean","boolean");

        //原始类型
        primitive2BoxMap.put("int","Integer");
        primitive2BoxMap.put("byte","Byte");
        primitive2BoxMap.put("char","Character");
        primitive2BoxMap.put("short","Short");

        primitive2BoxMap.put("long","Long");
//        primitive2BoxMap.put("float","Float");
//        primitive2BoxMap.put("double","Double");
//        primitive2BoxMap.put("boolean","Boolean");
    }

    //包装类型
    private static List<String> boxTypeList=new ArrayList<>();
    static {
        boxTypeList.add("Integer");
        boxTypeList.add("Byte");
        boxTypeList.add("Character");
        boxTypeList.add("Short");

        boxTypeList.add("Long");
//        boxTypeList.add("Float");
//        boxTypeList.add("Double");
//        boxTypeList.add("Boolean");
    }

    //包装类型
    private static List<String> primitiveTypeList=new ArrayList<>();

    static {
        primitiveTypeList.add("int");
        primitiveTypeList.add("byte");
        primitiveTypeList.add("char");
        primitiveTypeList.add("short");

        primitiveTypeList.add("long");
//        primitiveTypeList.add("float");
//        primitiveTypeList.add("double");
//        primitiveTypeList.add("boolean");
    }

    //得到原始类型
    public static List<String> getPrimitiveTypeList(){
        return new ArrayList<>(primitiveTypeList);
    }

    //得到包装类型
    public static List<String> getBoxTypeList(){
        return new ArrayList<>(boxTypeList);
    }

    /**
     * 根据原始类型得到包装类型
     * @param primitiveType
     * @return
     */
    public static String getBoxByPrimitive(String primitiveType){
        return primitive2BoxMap.get(primitiveType);
    }

    /**
     * 根据包装类型得到原始类型
     * @param boxType
     * @return
     */
    public static String getPrimitiveByBox(String boxType){
        return box2primitiveMap.get(boxType);
    }

    /**
     * 得到IEnum支持的类型
     * @return
     */
    public static List<String> getIEnumType(){

        List<String> boxTypeList = getBoxTypeList();
        boxTypeList.add("String");
        return boxTypeList;
    }

    /**
     * 得到switch类型
     * @return
     */
    public static List<String> getSwitchType(){
        List<String> list=new ArrayList<>();
        list.add("Integer");
        list.add("Byte");
        list.add("Character");
        list.add("Short");
        list.add("String");
        return list;
    }

    /**
     * 得到所有类型
     * @return
     */
    public static List<String> getAllList(){
        List<String> list=new ArrayList<>();
        list.addAll(getPrimitiveTypeList());
        list.addAll(getBoxTypeList());
        list.add("String");
        return list;
    }

}
